#include "Library.h"
#include"Observer.h"

Library::Library(void)
{
	m_pObserverList = new list<Observer*>();
}


Library::~Library(void)
{
	list<Observer*>::iterator ite = m_pObserverList->begin();
	while (ite != m_pObserverList->end())
	{
		delete (*ite);
		ite++;
	}
	delete m_pObserverList;
}

void Library::Attach(Observer *pObserver)
{
	m_pObserverList->push_back(pObserver);
}

void Library::Detach(Observer *pObserver)
{
	m_pObserverList->remove(pObserver);
}

void Library::Notify()
{
	list<Observer*>::iterator ite = m_pObserverList->begin();
	while (ite != m_pObserverList->end())
	{
		(*ite)->Update(this);
		ite++;
	}
}

void Library::SetData(string data)
{
	this->m_Data = data;
}

string Library::GetData()
{
	return this->m_Data;
}
